<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<div class="bjui-pageContent" style="top: 0px; bottom: 32px;">
    <form id="updateOrAddDic_form_id" method="post" action="/admin/dataMap/dictionaries/updateOrAddDic">
        <h5>${title}</h5>
        <div class="bjui-row col-2">
            <input type="hidden" name="id" value="${dictionaries.id}">
            <input type="hidden" name="pId" value="${pid}">
            <p>
                <label class="row-label">K</label>
                <span class="datagrid-dialog-column-span">
                    <input type="text" name="key" value="${dictionaries.key}"
                           data-rule-key="[/^[0-9a-zA-Z\u4e00-\u9fa5]{1,30}$/,'key格式错误']">
                </span>
            </p>

            <p>
                <label class="row-label">V</label>
                <span class="datagrid-dialog-column-span">
                    <input type="text" name="name" value="${dictionaries.name}" data-rule="required"><%--;letters--%>
                </span>
            </p>
        </div>
    </form>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li>
            <button type="button" class="btn btn-red cancel" onclick="BJUI.dialog('closeCurrent');" data-icon="remove">
                <i class="fa fa-remove"></i> 取消
            </button>
        </li>
        <li>
            <button type="button" class="btn btn-default save" onclick="updateOrAddDic();" data-icon="save"><i
                    class="fa fa-save"></i> 保存
            </button>
        </li>
    </ul>
</div>
<script>

    /**
     * 提交保存信息
     */
    function updateOrAddDic() {
        if (/^[0-9a-zA-Z\u4e00-\u9fa5]{1,30}$/.test($("input[name='key']").val())) {
            BJUI.ajax('ajaxform', {
                url: '/admin/dataMap/dictionaries/updateOrAddDic',
                form: $("#updateOrAddDic_form_id"),
                validate: true,
                loadingmask: true,
                callback: function (response, options) {
                    if (response.haveError) {
                        BJUI.alertmsg('error', response.message);
                    } else {
                        BJUI.alertmsg('ok', response.message, {
                            okCall: function () {
                                BJUI.navtab('refresh');
                                BJUI.dialog('closeCurrent');
                            }
                        });
                    }
                }
            });
        } else {
            BJUI.alertmsg("warn", "key格式错误")
        }
    }
</script>
